package procsim;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class AboutDialog extends JDialog implements ActionListener, KeyListener {
    private JPanel panel = new JPanel(new BorderLayout());
    private JPanel panelSouth = new JPanel(new FlowLayout());
    private JButton button = new JButton("Cancel");
    private JTextArea ta = new JTextArea(40, 30);
    AboutDialog(){
        setTitle("About this program");
        ta.setEditable(false);
        ta.setForeground(new Color(20, 20, 50, 200));
        ta.setLineWrap(true);
        ta.setWrapStyleWord(true);
        ta.addKeyListener(this);
        ta.setText("Processor simulator for Computer Architecture and Design 2 course\n\n"+
                    "Project made by:\n"+
                    "Filip Maljković, 06/0162\n"+
                    "Nemanja Preković, 05/0199\n"+
                    "Biljana Anđelković, 06/0035\n"+
                    "Miloš Tošić, 05/0066\n\n");
        button.addActionListener(this);
        button.addKeyListener(this);
        panelSouth.add(button);
        panel.add(ta, "Center");
        panel.add(panelSouth, "South");
        setContentPane(panel);
        setSize(300, 210);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(HIDE_ON_CLOSE);
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand().equals("Cancel")){
            setVisible(false);
        }
    }
    @Override
    public void keyTyped(KeyEvent ke) { }
    @Override
    public void keyPressed(KeyEvent ke) {
        if(ke.getKeyCode()==KeyEvent.VK_ESCAPE || ke.getKeyCode()==KeyEvent.VK_ENTER){
            setVisible(false);
        }
    }
    @Override
    public void keyReleased(KeyEvent ke) { }
}
